package com.example.notificationmodule

import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import androidx.core.app.NotificationCompat

class MainActivity : AppCompatActivity() {
	lateinit var manager:NotificationManager
	override fun onCreate(savedInstanceState: Bundle?) {
		super.onCreate(savedInstanceState)
		setContentView(R.layout.activity_main)
		 manager=getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
		if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.O){
			val channel = NotificationChannel("normal","Normal", NotificationManager.IMPORTANCE_DEFAULT)
			manager.createNotificationChannel(channel)
		}


	}

	fun sendNotification(view: View) {
		val notification=NotificationCompat.Builder(this,"normal")
				.setContentTitle("标题")
				.setContentText("内容")
				.build()
		manager.notify(1,notification)

	}
}